//
//  JSNetWorkingModel.m
//  WebView
//
//  Created by XDD on 16/5/31.
//  Copyright © 2016年 XDD. All rights reserved.
//

#import "JSNetWorkingModel.h"
#import "Globels.h"


@implementation JSNetWorkingModel

//救助中心站点列表
- (void)JS_HomeGetstation:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:station_JS WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Station_JS];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//关爱活动详情
- (void)JS_HomeGetact_info:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:act_info WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Act_info];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//志愿者详情
- (void)JS_HomeGetaccord_info:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:accord_info WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Accord_info];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//信息查询详情
- (void)JS_HomeGetmsg_open:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:open_masgess WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Open_masgess];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//公益伙伴
- (void)JS_HomeGetHelper:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:station_news_Pulic WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Helper];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//公益伙伴详情
- (void)JS_HomeGetHelper_Detail:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:station_news_Pulic_Detail WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Helper_Detail];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//关于我们站点详情
- (void)JS_HomeGetStand_listDetail:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:stand_List_Detail WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Stand_listDetail];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//物资流向详情
- (void)JS_HomeGetInformationDetail:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:information_Detail WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:InformationDetail];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//救助项目详情
- (void)JS_HomeGetHelp_News_info:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:help_news_Detail WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Help_News_info];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//救助项目首页
- (void)JS_HomeGetHelpItems:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:help_project WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:HelpItems];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//我的回复首页
- (void)JS_HomeGetMy_message:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:my_message WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:My_message];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//我的救助详情
- (void)JS_HomeGetMyHelp_Detail:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:my_HelpDetail WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:MyHelp_Detail];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//我的发布详情
- (void)JS_HomeGetMyPublic_Detail:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:my_PublicDetail WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:MyPublic_Detail];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

//系统提醒
- (void)JS_HomeGetSys_alert:(NSMutableDictionary *)dic {
    __block JSNetWorkingModel *weakSelf = self;
    [NetRequestClass NetCommonRequest:dic withUrl:system_Warning WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf fetchValueSuccessWithData:returnValue with:Sys_alert];
        
    } WithErrorCodeBlock:^(id errorCode) {
        
        self.errorBlock(errorCode);
    }];
}

#pragma mark -- 数据返回处理
- (void)fetchValueSuccessWithData:(id)data with:(interface_personal_JS)method {
    NSData *dataDic = [Globels dataWithJsonString:data];
    
   NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:dataDic
                                    options:NSJSONReadingMutableContainers
                                      error:nil];

    NSString *statu = [dict objectForKey:@"statu"];
//    NSString *result = [dict objectForKey:@"result"];
    
    switch (method) {
        case Station_JS:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Act_info:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Accord_info:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Open_masgess:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Helper:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Helper_Detail:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Stand_listDetail:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case InformationDetail:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                NSLog(@"%@",dict);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case HelpItems:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case My_message:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Help_News_info:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case MyHelp_Detail:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
                NSLog(@"%@",dict);

            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case MyPublic_Detail:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
                NSLog(@"%@",dict);
                
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
        case Sys_alert:
            if ([statu integerValue] == 0) {
                
                //获取成功
                self.returnBlock(dataDic);
                NSLog(@"JS数据请求成功");
                NSLog(@"%@",dict);
                
            }
            else {
                //获取失败
                NSLog(@"JS数据请求失败");
                self.errorBlock(dataDic);
                
                // [SVProgressHUD showInfoStatus:result afterDelay:2.0];
            }
            break;
    }
}

@end
